#include "array01.h"
#include "guessing_numbers.h"
#include "iostream"
#include "math_functions.h"
#include "sum_100.h"
#include "switch_demo.h"

using namespace std;

//#define PI 3.14
//#define ZG true


/**
 *
 * @return
 */
int main() {
    // 设置编码
    //system("chcp 65001");

    //cout << "Hello, World!" << endl;
    //cout << 100 << endl;
    //cout << "hello " << "world " << "c++" << endl;
    //21;
    //190.00;
    //"java";
    //'a';
    //true;
    //false;
    //cout << 21 << endl;
    //cout << 190.00 << endl;
    //cout << "java" << endl;
    //cout << 'a' << endl;
    //cout << true << endl;
    //cout << false << endl;


    //int a = 100;
    //cout << a << endl;
    //a++;
    //cout << a << endl;
    //cout << PI << endl;
    //cout << "你好" << endl;

    //string name = "java";
    //cout << name << endl;

    //short b = 100;
    //cout << b << endl;

    //long c = 100;
    //cout << c << endl;

    //long long d = 100;
    //cout << d << endl;

    //cout << "short占据的字节数是:" << sizeof(b) << endl;
    //cout << "long占据的字节数是:" << sizeof(c) << endl;
    //cout << "long long占据的字节数是:" << sizeof(d) << endl;
    //cout << "int占据的字节数是:" << sizeof(a) << endl;

    //有符号 unsigned 必须是大于0
    //unsigned int e = 100;
    //u_int f = 100;
    //cout << f << endl;
    //cout << e << endl;

    //float g = 100.00;
    //double h = 100.00;
    //cout << g << endl;
    //cout << h << endl;

    //char ch = 97;
    //cout << ch << endl;

    //cout << "你好呀\n我喜欢你" << endl;

    //string str = "java";
    ////cout << sizeof(str) << endl;
    //cout << str << endl;
    //string str2 = "c++";
    //string str3 = "c";
    //cout << str2 << endl;
    //cout << str3 + str2 << endl;

    ////字符串的拼接+，但是只能拼接字符串和字符串，其他的需要用to_string()函数
    //int i = 100;
    //string basic_string = to_string(i);
    //cout << str3 + basic_string << endl;

    //int aa;
    //cin >> aa;
    //cout << aa << endl;

    //string str4;
    //cin >> str4;
    //cout << str4 << endl;

    //0代表假，1代表真

    //三元表达式
    //int num1, num2;
    //cout << "请输入第一个整数" << endl;
    //cin >> num1;
    //cout << "请输入第二个整数" << endl;
    //cin >> num2;
    //string str10 = num1 > num2 ? "num1大于num2" : "num1小于num2";
    //cout << str10 << endl;

    //printFilesInDirectory("/Users/zhanggang/Desktop/阿努纳奇");

    //int money = 10000;
    //if (money >= 10000) {
    //    cout << "金额>=10000" << endl;
    //}else {
    //    cout << "金额<10000" << endl;
    //}

    //猜数字小游戏
    //guessing_numbers();

    //在C++里。0是false，1是true。
    //<< 是输出运算符，>> 是输入运算符。

    //switch_demo练习
    //switch_demo();

    //枚举
    //enum Color {
    //    RED, //默认是0开始
    //    BLUE, //1
    //    GREEN //2
    //};

    //求和
    //int sum_101 = sum_100(100);
    //cout << sum_101 << endl;

    //99乘法表
    //for (int i = 1; i <= 9; i++) {
    //    for (int j = 1; j <= i; j++) {
    //        cout << j << "*" << i << "=" << i * j << "\t";
    //    }
    //    //换行
    //    cout << endl;
    //}

    //cout << "-----------" << endl;

    //剔出3和5的倍数
    //for (int i = 1; i <= 10; ++i) {
    //    if (i % 3 == 0 || i % 5 == 0) {
    //        continue;
    //    }
    //    cout << i << "\t" << endl;
    //}
    //cout << "-------------" << endl;

    //int i = 1;
    //A:
    //cout << i << endl;
    //if (i < 10) {
    //    i++;
    //    goto A;
    //}
    //cout << "-------------" << endl;


    //int arr[10];
    //for (int i = 0; i <= 9; ++i) {
    //    arr[i] = i;
    //    cout << arr[i] << endl;
    //}
    //cout << "-------------" << endl;

    //int arr1[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    //for (int i = 0; i <= 9; ++i) {
    //    cout << arr1[i] << endl;
    //}

    //数组练习,猜数字
    //int array_count = array01();
    //cout << "数组练习,猜数字，猜对了" << +array_count << "次" << endl;


    //int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
    ////获取数组长度
    //unsigned long x = sizeof(arr) / sizeof(arr[0]);
    ////基础for遍历数组
    //for (int i = 0; i < x; ++i) {
    //    cout << arr[i] << endl;
    //}

    ////增强for遍历数组
    //for (int arr1: arr) {
    //    cout << arr1 << endl;
    //}

    ////二维数组
    //int arr2[2][3] = {
    //        {1, 2, 3},
    //        {4, 5, 6}
    //};

    //指针就是内存地址的意思
    //int num = 10;
    //int *p;
    //p = &num;
    //cout << "num的地址是:" << p << endl;//num的地址是:0x16ba27608
    //cout << "num的的值是:" << *p << endl;//num的的值是:10

    //int num2 = 10;
    //int *p2 = &num2;
    //cout << "num2的地址是:" << &p2 << endl;//num2的地址是:0x16ba275f0
    //cout << "num2的值是:" << *p2 << endl;//num2的值是:10

    ////改变num2的值,操作指针
    //*p2 = 20;
    //cout << "num2的值是:" << *p2 << endl;//num2的值是:20
    //cout << "num2的值是:" << num2 << endl;//num2的值是:20

    //空指针,声明方式
    //int *p = NULL;
    //int *b = nullptr;

    //int *p =new int;
    //*p =100;
    //cout << p << endl;
    //cout << "new是申请的4字节空间" << endl;
    //delete p;

    //int *p_arr =new int[5];
    //p_arr[0] = 1;
    //p_arr[1] = 2;
    //p_arr[2] = 3;
    //p_arr[3] = 4;
    //p_arr[4] = 5;
    //cout << p_arr << endl;
    //for (int i = 0; i < 5; ++i) {
    //    cout << p_arr[i] << endl;
    //}
    //delete[] p_arr;

    //移除下标为0和下标为5的2个元素
    int *pArr = new int [10]{3, 5, 1, 11, 99, 66, 22, 2, 8, 6};
    int *pArr2 = new int [8];
    cout << pArr << endl;
    cout << pArr2 << endl;
    for (int i = 0, j = 0; i < 10; ++i) {
        if (i != 0 && i != 5) {
            // 跳过下标为0和5的元素
            pArr2[j++] = pArr[i];
        }
    }

    // 打印新数组
    for (int i = 0; i < 8; ++i) {
        std::cout << pArr2[i] << " ";
    }
    cout << endl;

    // 清理内存
    delete[] pArr;
    delete[] pArr2;


    struct Student {
        string name;
        int age;
        string gender;
    };
    struct Student stu;
    stu = {"zhangsan", 18, "男"};


    return 0;
};
